package com.eshin.autotest.service;

import com.eshin.autotest.bean.OrderBean;
import jdk.nashorn.internal.objects.annotations.Constructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.concurrent.Executor;

/**
 * @author Eshin
 * @title: HelloService
 * @projectName pay
 * @date 2019/5/2710:58
 */

@Component
//@Scope(value = "singleton",proxyMode = ScopedProxyMode.TARGET_CLASS)
public class TestService implements IService{

    @PostConstruct
    public void init(){
        System.out.println("test service init...");
    }

    @Autowired
    HelloService helloService;

    OrderBean orderBean;

    public TestService(){}
    @Autowired
    public TestService(OrderBean orderBean) {
        this.orderBean = orderBean;
    }


//    @Autowired
//    public TestService(Executor executor,OrderBean orderBean){}
//    public TestService(OrderBean orderBean,Executor executor){}
/**
 * 相互引用的双方，如果均使用构造方法注入，则会出现死循环，双方都不能构造出实例，双方都在等对方的实例
 * 其中一方用autowired，另一方用构造器则不会出现死循环
 */
//    HelloService helloService;
//    public TestService(HelloService helloService) {
//        this.helloService =   helloService;;
//    }


    @Async
    public void doService(){
        System.out.println(Thread.currentThread().getName());
        System.out.println("test Service");
    }
}
